PUT Statement (Graphics) ---------------------------------------------------------------------------- Action Places a graphic image obtained by a GET statement onto the screen. Syntax PUT STEP ( x!, y!), arrayname# ( indexes%) , actionverb Remarks The list below describes the parts of the PUT statement. ----------------------------------------------------------------------------- Part Description ---------------------------------------------------------------------------- STEP Keyword indicating that the given x and y coordinates are relative to the most recently plotted point. The coordinates are treated as distances from the most-recent cursor location, not distances from the (0,0) screen coordinate. For example, if the most recent cursor location were (10,10) then the following statement would put the object stored in Ball at (20,15). PUT STEP (10,5),Ball Part Description ---------------------------------------------------------------------------- PUT STEP (10,5),Ball ( x!, y!) Coordinates that specify the top-left corner of the rectangle enclosing the image to be placed in the current output window. The entire rectangle to be put on the screen must be within the bounds of the current viewport. Note that if a WINDOW statement without the argument SCREEN appears in a program before PUT, the coordinates refer to the lower-left corner of the rectangle. arrayname# The name of the array that holds the image. See the GET statement for information about the number Part Description ---------------------------------------------------------------------------- for information about the number of elements that are required in the array, which can be multidimensional. indexes% Specifies that the image is retrieved starting from the designated array element, rather than at the first array element. actionverb Determines interaction between stored image and the one already on the screen. This allows display of the image with special effects. The different values for actionverb are described in the following list. The default actionverb value is XOR. ----------------------------------------------------------------------------- Verb Description ---------------------------------------------------------------------------- XOR Causes the points on the screen to be inverted where a point exists in the array image. When an image is placed on the screen against a complex background twice, the background is restored. This behavior is exactly like that of the cursor. You can move an object around the screen without erasing the background, thus creating animation effects. PSET Transfers the data point-by-point onto the screen. Each point has the exact color attribute it had when it was taken from the screen with GET. The PSET argument Verb Description ---------------------------------------------------------------------------- with GET. The PSET argument draws the image as stored, wiping out any existing image. PRESET The same as PSET except that a negative image (for example, black on white) is produced. AND Used when the image is to be transferred over an existing image on the screen. The resulting merged image is the result of a logical- AND operation on the stored image and the screen. Points that had the same color in both the existing image and the stored image remain the same color. Points that do not have the same color in both the existing image Verb Description ---------------------------------------------------------------------------- color in both the existing image and the stored image do not. OR Used to superimpose the image onto an existing image. The resulting image is the product of a logical- OR operation on the stored image and the screen image. The stored image does not erase the previous screen contents. See Also GET (Graphics) Example The following example creates a moving white ball that ricochets off the sides of the screen until you press a key. DEFINT A-Z DIM Ball(84)' Set the dimensions for an integer array large ' enough to hold ball. SCREEN 2' 640 pixels by 200 pixels screen resolution. INPUT "Press any key to end; press to start", Test$ CLS CIRCLE (16, 16), 14' Draw and paint ball. PAINT (16, 16), 1 GET (0, 0)-(32, 32), Ball X = 0 . Y = 0 Xdelta = 2 . Ydelta = 1 DO ' Continue moving in same direction as long as ball is within ' the boundaries of the screen - (0,0) to (640,200). X = X + Xdelta . Y = Y + Ydelta IF INKEY$ <> "" THEN END ' Test for key press. ' Change X direction if ball hits left or right edge. IF (X < 1 OR X > 600) THEN Xdelta = -Xdelta BEEP END IF ' Change Y direction if ball hits top or bottom edge. IF (Y < 1 OR Y > 160) THEN Ydelta = -Ydelta BEEP END IF ' Put new image on screen, simultaneously erasing old image. PUT (X, Y), Ball, PSET LOOP END